package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.data.attribute.CellAttrs;
import org.akomantoso.core.io.Input;
import org.akomantoso.core.io.Output;

/**
 * The element td is an HTML element and is used in Akoma Ntoso as in HTML, for a data cell of a table.
 * 
 * <pre>
 * <xsd:element name="td">
 * 		<xsd:complexType>
 * 			<xsd:complexContent>
 * 				<xsd:extension base="blocksopt">
 * 					<xsd:attributeGroup ref="cellattrs"/>
 * 				</xsd:extension>
 * 			</xsd:complexContent>
 * 		</xsd:complexType>
 * </xsd:element>
 * </pre>
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 * 
 * @since http://www.akomantoso.org/1.0
 */
public final class Td extends Blocksopt implements CellAttrs , TrElement {

	private int _rowSpan = 1;
	private int _colSpan = 1;
	
	/**
	 * @see org.akomantoso.core.data.attribute.CellAttrs#getRowSpan()
	 */
	public int getRowSpan() {
		return _rowSpan;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.CellAttrs#setRowSpan(int)
	 */
	public void setRowSpan(int rowspan) {
		_rowSpan = rowspan;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.CellAttrs#getColSpan()
	 */
	public int getColSpan() {
		return _colSpan;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.CellAttrs#setColSpan(int)
	 */
	public void setColSpan(int colspan) {
		_colSpan = colspan;
	}

	
	/**************************************************************************
	 * 							Externalisation
	 **************************************************************************/
	
	/**
	 * @see org.akomantoso.core.data.Blocksopt#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <T extends Output> void writeExternal(T out) throws IOException {
		out.writeStart("td");
		super.writeExternal(out);
		out.writeEnd();
	}

	/**
	 * @see org.akomantoso.core.data.Blocksopt#readExternal(org.akomantoso.core.io.Input)
	 */
	@Override
	public <T extends Input> void readExternal(T in) throws IOException {
		super.readExternal(in);
	}
	
}